package apiexample.transform.statistics;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.PrintStream;
import java.sql.Connection;
import java.util.HashSet;
import java.util.Random;

import com.apiexample.server.dao.BaseDao;
import com.apiexample.server.dao.ExampleDao;
import com.apiexample.server.entity.ExampleEntity;

public class RandomExp {

	/**
	 * @param args
	 * @throws FileNotFoundException 
	 */
	public static void main(String[] args) throws FileNotFoundException {
		// TODO Auto-generated method stub
		PrintStream fos_out = new PrintStream(new File("M:/apiexample/randomPageList4Exp.txt"));
		System.setOut(fos_out);
		
		Connection server_conn = BaseDao.getTestConn();
		HashSet<String> linkSet = new HashSet<String>();
		Random random = new Random();
		for ( int i = 0;i<200;i++){
			int next = random.nextInt(140000);
			System.err.println(next);
			ExampleEntity example = ExampleDao.getExampleByID(server_conn, next);
			if(example!=null){
				if(linkSet.add(example.getSource())){
					System.out.println(example.getSource());
				}
			}
		}
		
		fos_out.close();
	}

}
